from wcs.libs.players import players
from wcs.libs.items import items

itemName = 'Potion of Invulnerability'
item = items.addItem(itemName)
item.setGroup("powerup")
item.setCost(3750)
item.setDescription("The gods protect you for 7 seconds")
item.aliveTouse = True
item.setMaxCount(1)

def wcs_item_bought(event_var):
    """
    Executed when a player has purchased an item. If the item purcahsed was this
    item, then ensure that we set them as invulnerable for 7 seconds.
    """
    if event_var['item'] == itemName:
        userid = event_var["userid"]
        player = players[userid]
        player.god(7)
